import java.util.*;

public class demo1 {
    static boolean is_T ;
    public int getFirstUnFormedNum(int[] arr) {
        //01 背包
        Arrays.sort(arr);
        int min = arr[0];
        int max = 0;
        for (int i = 0; i < arr.length; i++) {
            max += arr[i];
        }
        int row = arr.length;
        int col = max;
        int[][] dp = new int[row + 1][col + 1];
        for (int i = 0; i < dp.length; i++) {
            dp[i][0] = 0;
        }
        for (int i = 0; i < dp[0].length; i++) {
            dp[0][i] = 0;
        }
        for (int i = 1; i < dp.length; i++) {
            for (int j = 1; j < dp[0].length; j++) {
                if(arr[i-1] <= j){
                    dp[i][j] = Math.max(dp[i-1][j],arr[i-1]+dp[i-1][j-arr[i-1]]);
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        for(int i = min+1; i <= max; i++){
            if(dp[row][i] == dp[row][i-1]){
                return i;
            }
        }
        return max+1;
    }
}
